package wotd.web;

import wotd.BibleQuery;
import wotd.VerseLookup;
import wotd.GCacheVerseLookup;
import wotd.esv.EsvQuery;

import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.inject.servlet.ServletModule;

public class WotdServletConfig extends GuiceServletContextListener {

	@Override
	protected Injector getInjector() {
		return Guice.createInjector(
				new WotdServletModule(),
				new WotdModule());
	}
	
	private static class WotdServletModule extends ServletModule {
		@Override
		protected void configureServlets() {
			serve("/wotd").with(WotdServlet.class);
			serve("/all").with(AllVersesServlet.class);
			serve("/lookup").with(LookupServlet.class);
			serve("/fb").with(FacebookServlet.class);
		}
	}
	
	private static class WotdModule extends AbstractModule {
		@Override
		protected void configure() {
			bind(VerseLookup.class).to(GCacheVerseLookup.class);
			bind(BibleQuery.class).to(EsvQuery.class);
		}
	}
}
